package com.airticketbooking.service.serviceImpl;

import com.airticketbooking.common.domain.PageQuery;
import com.airticketbooking.common.utils.BeanUtils;
import com.airticketbooking.po.Seat;
import com.airticketbooking.vo.SeatVO;
import com.airticketbooking.mapper.SeatMapper;
import com.airticketbooking.service.SeatService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author Mr.J
 * @version 1.0.0
 * @date 2024/10/12
 * @desc
 */

@Service
@RequiredArgsConstructor
public class SeatServiceImpl implements SeatService {


	private final SeatMapper seatMapper;



	@Override
	public Page<SeatVO> list(PageQuery pageQuery, Integer classId,Integer shceduleId) {

		PageHelper.startPage(pageQuery.getPageNo(), pageQuery.getPageSize());



		Page<SeatVO> seatsVo = seatMapper.list(classId,shceduleId);

		return seatsVo;
	}

	@Override
	public SeatVO getById(Integer seatId) {

		Seat seat = seatMapper.getById(seatId);

		SeatVO seatVO = new SeatVO();
		BeanUtils.copyProperties(seat, seatVO);

		return seatVO;

	}

	@Override
	public List<Seat> getSeatsByAirplaneId(Integer airplaneId) {

		List<Seat> seats = seatMapper.getSeatsByAirplaneId(airplaneId);
		return seats;

	}

	@Override
	@Transactional
	public void updateSeat(Seat seat) {

		seatMapper.updateSeat(seat);
	}


}
